<?php TPL::output('m/header.tpl.htm'); ?>

<!-- 内容 -->
	<div class="container padding-0">
		<!-- 话题bar -->
		<div class="aw-topic-bar clearfix" data-id="<?php echo $this->article_info['id']; ?>" data-type="article">
			<div class="tag-bar">
				<?php foreach($this->article_topics as $key => $val) { if ($key > 2) { break; } ?>
					<span class="topic-tag" data-id="<?php echo $val['topic_id']?>">
						<a class="text" href="m/topic/<?php echo $val['url_token']; ?>"><?php echo $val['topic_title']; ?></a>
					</span>
				<?php } ?>
				<?php if ($this->user_id) { ?>
					<a class="icon icon-inverse aw-add-topic-box"><i class="icon icon-edit"></i> <?php if (!count($this->article_topics) > 0) { ?>添加话题<?php } ?></a>
				<?php } ?>
			</div>
		</div>
		<!-- end 话题bar -->

		<!-- 文章详情 -->
		<div class="aw-question-detail aw-article-detail">
			<div class="mod-head">
				<h1><?php echo $this->article_info['title']; ?></h1>
			</div>
			<div class="mod-body">
				<div class="markitup-box clearfix">
					<?php echo $this->article_info['message']; ?>
					<div id="weixin-desc" style="display:none;">
						<?php echo cjk_substr(str_replace(array("\r","\n"),array(' ',' '), strip_tags($this->article_info['message'])), 0, 130, 'UTF-8', '...');?>
					</div>
									
					<?php if ($this->article_info['attachs']) {  ?>
					<div class="aw-upload-img-list">
					<?php foreach ($this->article_info['attachs'] AS $attach) { ?>
					<?php if ($attach['is_image'] AND !in_array($attach['id'], $this->article_info['attachs_ids'])) { ?>
						<a href="<?php echo $attach['attachment']; ?>" target="_blank" data-fancybox-group="thumb" rel="lightbox"><img src="<?php echo $attach['attachment']; ?>" class="img-polaroid" alt="<?php echo $attach['attach_name']; ?>" /></a>
					<?php } ?>
					<?php } ?>
					</div>
					<?php } ?>
					
					<?php if ($this->article_info['attachs']) {  ?>
					<ul class="aw-upload-file-list">
						<?php foreach ($this->article_info['attachs'] AS $attach) { ?>
						<?php if (!$attach['is_image'] AND !in_array($attach['id'], $this->article_info['attachs_ids'])) { ?>
							<li><a href="<?php echo download_url($attach['file_name'], $attach['attachment']); ?>"><i class="icon icon-attach"></i> <?php echo $attach['file_name']; ?></a></li>
						<?php } ?>
						<?php } ?>
					</ul>
					<?php } ?>
				</div>
			</div>
			<div class="mod-footer active">
				<span class="pull-right">
					<a onclick="AWS.User.share_out({webid:'tsina'});"><i class="icon icon-weibo"></i></a>
				</span>
				<span class="aw-article-vote operate <?php if (!$this->user_id OR $this->user_id == $this->article_info['uid']) { ?> disabled<?php } ?>">
					<a class="agree" <?php if ($this->user_id AND $this->user_id != $this->article_info['uid']) { ?>onclick="AWS.User.article_vote($(this), <?php echo $this->article_info['id']; ?>, 1);"<?php } ?>><i class="icon icon-agree <?php if ($this->article_info['vote_info']['rating'] == 1) { ?> active<?php } ?>"></i> <b><?php echo $this->article_info['votes']; ?></b></a>
					<a class="disagree" <?php if ($this->user_id AND $this->user_id != $this->article_info['uid']) { ?>onclick="AWS.User.article_vote($(this), <?php echo $this->article_info['id']; ?>, -1);"<?php } ?>><i class="icon icon-disagree <?php if ($this->article_info['vote_info']['rating'] == -1) { ?> active<?php } ?>"></i></a>
					<a onclick="AWS.User.favorite('article', <?php echo $this->article_info['id']; ?>);">
						<i class="icon icon-favor"></i>
					</a>
				</span>
				<!-- 赞同列表 -->
				<?php if ($this->article_info['vote_users']) { ?>
				<div class="aw-article-voter">
					<?php foreach ($this->article_info['vote_users'] AS $key => $val) { ?>
					<a href="people/<?php echo $val['url_token']; ?>" class="voter" data-toggle="tooltip" data-placement="right" data-original-title="<?php echo $val['user_name']; ?>"><img class="img" width="20" alt="<?php echo $val['user_name']; ?>" src="<?php echo get_avatar_url($val['uid'], 'mid'); ?>" /></a>
					<?php } ?>
					<!--<a class="more-voters">...</a>-->
				</div>
				<?php } ?>
				<!-- end 赞同列表 -->
			</div>
		</div>
		<!-- end 文章详情 -->

		<!-- 回复列表 -->
		<div class="aw-replay-list">
			<div class="mod-head">
				<h2><?php _e('%s 个回复', $this->comments_count); ?></h2>
			</div>
			<?php if ($this->comments) { ?>
			<div class="mod-body">
				<ul>
					<?php foreach ($this->comments AS $key => $val) { ?>
					<li>
						<div class="mod-head">
							<span class="pull-right"><?php echo date_friendly($val['add_time']); ?></span>
							<a href="m/people/<?php echo $val['user_info']['url_token']; ?>"><img class="img" alt="" src="<?php echo get_avatar_url($val['uid'], 'mid'); ?>" width="20" /></a>
							<a href="m/people/<?php echo $val['user_info']['url_token']; ?>"><?php echo $val['user_info']['user_name']; ?></a>
							<?php if ($val['at_user_info']) { ?> <?php _e('回复'); ?> <a href="people/<?php echo $val['at_user_info']['url_token']; ?>"><?php echo $val['at_user_info']['user_name']; ?></a><?php } ?>
						</div>
						<div class="mod-body">
							<div class="markitup-box clearfix">
								<?php echo nl2br($val['message']); ?>
							</div>
						</div>
						<div class="mod-footer">
							<div class="meta">
								<?php if ($this->user_id) { ?>
								<a onclick="AWS.User.article_comment_vote($(this), <?php echo $val['id']; ?>, 1)"<?php if ($val['vote_info']['rating'] == 1) { ?> class="active"<?php } ?>><?php if ($val['vote_info']['rating'] == 1) { ?><?php _e('我已赞'); ?><?php } else { ?><?php _e('赞'); ?><?php } ?> (<b><?php echo $val['votes']; ?></b>)</a>&nbsp; • &nbsp;
								<a class="aw-article-comment" data-id="<?php echo $val['user_info']['uid']; ?>">回复</a>
								<?php } ?>
							</div>
						</div>
					</li>
					<?php } ?>
				</ul>
				<?php if ($_GET['item_id']) { ?>
				<a href="article/<?php echo $this->article_info['id']; ?>" class="aw-load-more"><?php _e('查看全部评论'); ?></a>
				<?php } ?>
			</div>
			<?php } ?>
		</div>
		<!-- end 回复列表 -->

		<a name="answer_form"></a>
		<?php if ($this->next_page) { ?>
		<a href="m/question/<?php echo $this->question_info['question_id']; ?>?page-<?php echo $this->next_page; ?>" class="aw-load-more">下一页</a>
		<?php } ?>
		
		<?php if ($this->article_info['lock']) { ?>
		<p align="center"><?php _e('该文章目前已经被锁定, 无法添加新评论'); ?></p>
		<?php } else if (!$this->user_id) { ?>
		<a class="aw-load-more" id="load_index_actions" href="account/login/"><?php _e('登录进行回复'); ?></a>
		<?php } else { ?>
		<!-- 回复box -->
		<div class="aw-replay-box article">
			<form action="article/ajax/save_comment/" onsubmit="return false;" method="post" id="answer_form">
				<input type="hidden" name="post_hash" value="<?php echo new_post_hash(); ?>" />
			    <input type="hidden" name="article_id" value="<?php echo $this->article_info['id']; ?>" />
				<div class="mod-head">
					<a href="m/people/"><img width="20" class="img" src="<?php echo get_avatar_url($this->user_id, 'mid'); ?>" alt="" /></a> <?php echo $this->user_info['user_name']; ?>
				</div>
				<div class="mod-body">
					<textarea class="form-control autosize" rows="5" name="message"></textarea>
				</div>
				<div class="mod-footer clearfix">
					<a class="btn btn-success btn-normal pull-right" onclick="AWS.ajax_post($('#answer_form'), AWS.ajax_processer, 'reply');"><?php _e('回复'); ?></a>
					<?php if ($this->human_valid) { ?>
					<div class="captcha pull-right clearfix">
						<input type="text" class="form-control" name="seccode_verify" placeholder="<?php _e('验证码'); ?>" />
						<img src="" class="img" onclick="this.src = G_BASE_URL + '/account/captcha/' + Math.floor(Math.random() * 10000);" id="captcha" />
					</div>
					<?php } ?>
				</div>
			</form>
		</div>
		<!-- end 回复box -->
		<?php } ?>
</div>
<!-- end 内容 -->

<?php TPL::output('m/footer.tpl.htm'); ?>